<style lang="less">

</style>
<template>
    <div>
        <Drawer :closable="false" placement="right" v-model="drawerVisible" width="50%" :title="drawerTitle">
            <Row>
                <Col>
                <Card :shadow="false">
                    <Row>
                        <Form ref="form" :model="form" :label-width="90" style="position:relative">
                            <FormItem label="国开学籍号" prop="schoolNum" v-if="form.schoolRegister == 2">
                                <Input v-model="form.schoolNum" :readonly="disabledSingle" style="width:600px"/>
                            </FormItem>
                            <FormItem label="拒绝原因" prop="reason" v-if="form.schoolRegister == 3">
                                <Input v-model="form.reason" :readonly="disabledSingle" style="width:600px"/>
                            </FormItem>
                            <FormItem label="审核结果" prop="schoolRegister" >
                                <RadioGroup v-model="form.schoolRegister" >
                                    <Radio :label="2" :disabled="disabledSingle">通过</Radio>
                                    <Radio :label="3" :disabled="disabledSingle">拒绝</Radio>
                                </RadioGroup>
                            </FormItem>
                            <Form-item class="br" v-if="!disabledSingle">
                                <Button type="primary" :loading="submitLoading" @click="handelSubmit" style="width:80px">提交</Button>
                                <Button @click="handelCancel">取消</Button>
                            </Form-item>
                            <Spin size="large" fix v-if="loading"></Spin>
                        </Form>
                    </Row>
                </Card>
                </Col>
            </Row>
        </Drawer>
    </div>
</template>
<script>
    import {userGkregisterSetStatus} from "@/api/bus";
    import uploadInput from "@/views/my-components/flyme/upload-input";
    // 表情包配置 自定义表情可在该js文件中统一修改
    import {sina} from "@/libs/emoji";
    export default {
        name: "gkregister-drawer",
        components: {
            uploadInput
        },
        data() {
            return {
                disabledSingle: false,
                picVisible: false,
                fileUrl: "",
                loading: false, // 表单加载状态
                drawerTitle: "国开注册申请审核",
                drawerVisible: false,
                form: {
                    reason: '',
                    schoolNum: '',
                    schoolRegister: 2
                },
                submitLoading: false, // 添加或编辑提交状态
            };
        },
        methods: {
            showDrawer(params) {
                this.form.id = params.id
                this.form.schoolNum = params.schoolNum
                this.form.registerStatus = params.registerStatus
                this.drawerVisible = true;
                if(params.registerStatus === 1){
                    this.disabledSingle = true
                }else{
                    this.disabledSingle = false
                }
                if(params.registerStatus === 2){
                    this.form.registerStatus = 1
                }
            },
            handelSubmit() {
                this.$refs.form.validate(valid => {
                    if (valid) {
                        if(this.form.registerStatus === 1){
                            if(!this.form.schoolNum){
                                this.$Message.error("请填写学籍号");
                                return false
                            }
                        }
                        this.submitLoading = true;
                        userGkregisterSetStatus(this.form).then(res => {
                            this.submitLoading = false;
                            if (res.status === true) {
                                this.$Message.success("操作成功");
                                this.$parent.getDataList();
                                this.drawerVisible = false;
                            }
                        });
                    }
                });
            },
            showPic(v) {
                this.fileUrl = v;
                this.picVisible = true;
            },
            handelCancel() {
                this.drawerVisible = false;
            }
        },
        mounted() {

        },
        watch: {

        }
    };
</script>